<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
namespace App\Api\Controllers\Commons;

use App\Api\BaseApi;
use App\Models\GroupOrderProduct;
use App\Models\GroupOrderSession;
use App\Models\GroupOrderSetting;

class GroupApi extends BaseApi
{
    public function groupProduct()
    {
        $res = GroupOrderProduct::query()
            ->where('status', 1)
            ->simplePaginate(request('perPage', 10));

        return responses($res);
    }

    public function groupProductDetails()
    {
        $request = self::validate([
            'group_product_id' => 'required',
        ]);
        $res = GroupOrderProduct::query()->find($request->get('group_product_id'));
        return responses($res);
    }

    public function groupBuyingSessions()
    {
        $first = GroupOrderSetting::query()->first()->daily_group_limit;
        return responses($first);
    }
}
